package com.jinyu.jyly.ui.mine.order.detail;

import android.content.Intent;
import android.widget.TextView;

import com.google.gson.Gson;
import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
import com.jinyu.jyly.R;
import com.jinyu.jyly.base.BaseActivity;
import com.jinyu.jyly.bean.AllInfoBean;
import com.jinyu.jyly.utils.AES;

import org.json.JSONException;
import org.json.JSONObject;

import butterknife.BindView;

/**
 * 订单详情
 */
public class OrderDetailActivity extends BaseActivity<OrderDetailPresenter> implements OrderDetailContract.View {

    @BindView(R.id.tv_order_state)
    TextView tv_order_state;


    private OrderDetailPresenter presenter;

    @Override
    public int getLayout() {
        return R.layout.activity_order_detail;
    }

    @Override
    protected OrderDetailPresenter getPresenter() {
        if (presenter == null) {
            presenter = new OrderDetailPresenter(this, this);
        }
        return presenter;
    }

    @Override
    protected void initEventAndData() {
        QMUIStatusBarHelper.translucent(this);
        QMUIStatusBarHelper.setStatusBarDarkMode(this);

        initInent();

    }

    private void initInent() {
        Intent intent = getIntent();
        int id = intent.getIntExtra("id",0);
        int status = intent.getIntExtra("status", 0);
        tv_order_state.setText(status+"");
        try {
            //获取mine
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("id", id);
            String param = AES.encryptToHexString(jsonObject.toString());
            presenter.getorderPayment(param);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onFailer(Throwable throwable) {

    }

    /**
     * 更具订单获取支付方式
     *
     * @param infoBean
     */
    @Override
    public void onGetOrderPayment(AllInfoBean infoBean) {
        switch (infoBean.getStatus()) {
            case 200:
                try {
                    String decrypt = AES.decrypt(infoBean.getData());
                    Gson gson = new Gson();
                } catch (Exception e) {
                    e.printStackTrace();
                }
        }
    }

    @Override
    public void onChangeOrder(AllInfoBean infoBean) {
        //空实现
    }

    @Override
    public void onUpdataImg(AllInfoBean infoBean) {

    }
}
